package com.frejoys.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.frejoys.common.vo.app.ChildUserCountVo;
import com.frejoys.dao.entity.UserLevel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserLevelMapper extends BaseMapper<UserLevel> {

    //查找推广者父级id
    @Select("select user_id from j_user_level where child_user_id = #{childId}")
    Long getParentId(@Param("childId") Long childId);

    List<ChildUserCountVo> getChildUserCount(@Param("userIds") List<Long> userIds);

    // 一级推荐人数
    @Select("select count(1) from j_user_level where user_id = #{userId}")
    Integer userLevelOneCount(@Param("userId") Long userId);

    // 二级推荐人数
    @Select("select count(1) from j_user_level where parent_user_id = #{userId}")
    Integer userLevelTwoCount(@Param("userId") Long userId);
}
